Can MySQL automatically specify `_utf8` for inserts to UTF-8 columns?
Posted
by Neil
on Stack Overflow
See other posts from Stack Overflow
or by Neil
Published on 2010-04-16T15:01:11Z
Indexed on
2010/04/16
15:03 UTC
Read the original article
Hit count: 145
I have a table like this, where one column is latin1, the other is UTF-8:
Create Table: CREATE TABLE `names` (
`name_english` varchar(255) character NOT NULL,
`name_chinese` varchar(255) character set utf8 default NULL,
) ENGINE=MyISAM DEFAULT CHARSET=latin1
When I do an insert, I have to type _utf8
before values being inserted into UTF-8 columns:
insert into names (name_english = "hooey", name_chinese = _utf8 "??");
However, since MySQL should know that name_chinese
is a UTF-8 column, it should be able to know to use _utf8
automatically.
Is there any way to tell MySQL to use _utf8
automatically, so when I'm programatically making prepared statements, I don't have to worry about including it with the right parameters?
© Stack Overflow or respective owner